package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * 说明:
 *
 * @author: luohaowei
 * @date:2023/3/3
 **/
public class SortString {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();

        list.add("姜承録");
        list.add("高振宁");
        list.add("宋义进");
        list.add("喻文波");
        list.add("王柳羿");
        list.add("李浩成");
        list.add("THESHY");
        list.add("NING");
        list.add("ROOKIE");
        list.add("JACKEYLOVE");
        list.add("BAOLAN");
        list.add("DUCK");
        System.out.println("list原始数据"+list);
        Collections.sort(list);
        System.out.println("list排序后数据:"+list);
        Collections.sort(list, new Comparator<String>() {

            public int compare(String o1, String o2) {
                return o1.length()-o2.length();
            }
        });
        Collections.sort(list,(o1,o2)->o1.length()-o2.length());
    }
}
